package my.edu.model.bills.sales.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import my.edu.common.domain.OrderProductDetail;
import my.edu.common.enumeration.OrderType;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

@Data
@TableName("sales_return_order_detail")
public class SalesReturnOrderDetail extends OrderProductDetail {
    @TableId(type = IdType.AUTO)
    private Long id;
    private Long salesReturnOrderId;
    private Long productId;
    private String productName;
    private String brand;
    private String productRemark;
    private String productAttributes;
    private String unit;
    private Long warehouseId;
    private String warehouseName;
    private Integer availableStock;
    private Integer wholePackage;
    private Integer quantity;
    private BigDecimal weight;
    private String basicUnit;
    private BigDecimal basicQuantity;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDate deliveryDate;
    private BigDecimal salesPrice;
    private Integer isGift;
    private BigDecimal estimatedPurchasePrice;
    private BigDecimal taxInclusivePrice;
    private BigDecimal discountTaxInclusivePrice;
    private BigDecimal discountRate;
    private BigDecimal discount;
    private BigDecimal discountAmount;
    private BigDecimal discountPrice;
    private BigDecimal amount;
    private BigDecimal taxRate;
    private BigDecimal taxAmount;
    private BigDecimal priceTaxTotal;
    private String remark;
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;
    @TableField(fill = FieldFill.UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;
    @TableField(fill = FieldFill.UPDATE)
    private Long updatedBy;

    @Override
    public BigDecimal getCurrentPrice() {
        return getSalesPrice();
    }

    @Override
    public void setCurrentPrice(BigDecimal price) {
        setSalesPrice(price);
    }

    @Override
    public OrderType getCurrentOrderType() {
        return OrderType.SALE_PRICE;
    }
}